home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 May: Tool Chest / Apple_Developer_CD_Series_May_1994_Tool_Chest.iso / Sample Code / AppsToGo / DTS.StyleChat / IdleTasks.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-24  |  2.5 KB  |  102 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:        IdleTasks.c
  5. ** Written by:    Eric Soldan
  6. **
  7. ** Copyright © 1990-1993 Apple Computer, Inc.
  8. ** All rights reserved.
  9. */
  10.  
  11. /* You may incorporate this sample code into your applications without
  12. ** restriction, though the sample code has been provided "AS IS" and the
  13. ** responsibility for its operation is 100% yours.  However, what you are
  14. ** not permitted to do is to redistribute the source as "DSC Sample Code"
  15. ** after having made changes. If you're going to re-distribute the source,
  16. ** we require that you make it clear in the source that the code was
  17. ** descended from Apple Sample Code, but that you've made changes. */
  18.  
  19. /* This function is called when a null event is received.  Do appropriate tasks
  20. ** for null event situations, such as handling balloon help for window. */
  21.  
  22.  
  23.  
  24. /*****************************************************************************/
  25.  
  26.  
  27.  
  28. #include "App.h"            /* Get the application includes/typedefs, etc.    */
  29. #include "App.protos.h"        /* Get the prototypes for application.            */
  30.  
  31. extern OSType    gAppWindowType;
  32. extern short    gDialogErr;
  33.  
  34. Boolean            gStartingUp = true;
  35.  
  36.  
  37.  
  38. /*****************************************************************************/
  39. /*****************************************************************************/
  40.  
  41.  
  42.  
  43. #pragma segment Main
  44. void    DoIdleTasks(EventRecord *event)
  45. {
  46. #ifndef __MWERKS__
  47. #pragma unused (event)
  48. #endif
  49.  
  50.     WindowPtr        ww;
  51.     FileRecHndl        ff;
  52.     ControlHandle    ctl;
  53.  
  54.     static long    waitSome;
  55.  
  56.     if (gStartingUp) {
  57.         if (FrontWindow()) {
  58.             gStartingUp = false;
  59.             waitSome = 0;
  60.             IsCtlEvent(nil, event, nil, nil);
  61.             return;
  62.         }
  63.         if (!waitSome) waitSome = TickCount() + 30;
  64.         else {
  65.             if (waitSome < TickCount()) {
  66.                 gStartingUp = false;
  67.                 waitSome    = 0;
  68.                 gDialogErr  = NewDocumentWindow(nil, gAppWindowType, true);
  69.                 if (gDialogErr)
  70.                     NewDocumentWindow(nil, 'ERR#', false);
  71.             }
  72.         }
  73.         IsCtlEvent(nil, event, nil, nil);
  74.         return;
  75.     }
  76.  
  77.     for (ww = nil; (ww = GetNextWindow(ww, gAppWindowType)) != nil;) {
  78.         ff = (FileRecHndl)GetWRefCon(ww);
  79.         if ((*ff)->connect.connected == 1) {
  80.             CNum2Ctl(ww, 1010, &ctl);
  81.             (*ctl)->contrlVis = false;
  82.             BeginFrame(ww);
  83.             CNum2Ctl(ww, 1020, &ctl);
  84.             ShowStyledControl(ctl);
  85.             CNum2Ctl(ww, 1000, &ctl);
  86.             ShowStyledControl(ctl);
  87.             EndFrame(ww);
  88.             (*ff)->connect.connected++;
  89.             BeginContent(ww);
  90.             SendMessage(ff, kStylMssg);
  91.             SendMessage(ff, kTextMssg);
  92.             EndContent(ww);
  93.         }
  94.     }
  95.  
  96.     if (TSMTEAvailable()) TSMEvent(event);
  97.     IsCtlEvent(nil, event, nil, nil);
  98. }
  99.  
  100.  
  101.  
  102.